import React,{Component} from 'react'

import Demo08_ref_children from './Demo08_ref_children'

import Demo09_ref_children2 from './Demo09_ref_children2'

export default class Demo07_ref_father extends Component {
  constructor(){
    super();
    this.state={
      info:''
    }
    this.RvcMassage=this.RvcMassage.bind(this)
  }
  handleClick(){
    console.log(this);
    console.log(this.refs.my.name);
    console.log(this.refs.myInput.value);
  }

  RvcMassage(msg){
    console.log('这个是从子组件input 传给父组件的值' + msg );
    this.setState({
      info:msg
    })
  }

  render(){
    return(
        <div>
          <p>Demo07_ref</p>
          <input type="text" ref="myInput"/>
          <br/>
          {/*//希望能够获取到 Demo08_ref_children 组件类中定义myName*/}
          <h1>这个是子组件A input</h1>
          <Demo08_ref_children save={this.RvcMassage} ref="my"/>
          <br/>
          <h1>这个是子组件B button </h1>
          <Demo09_ref_children2 myInfo={this.state.info} />
          <br/>
          <h1>这个是父组件里面的</h1>
          <button onClick={this.handleClick.bind(this)}>通过ref获取input值</button>
        </div>
    );
  }

}